<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      window.onload = function () {
        var a1 = document.getElementById("a1");
        var a2 = document.getElementById("a2");
        var a3 = document.getElementById("a3");
        var c1 = document.getElementById("content1");
        var c2 = document.getElementById("content2");
        var c3 = document.getElementById("content3");
        a2.onclick = function () {
          c2.style.opacity = 1;
          c1.style.opacity = 0;
          c3.style.opacity = 0;
        };
        a1.onclick = function () {
          c2.style.opacity = 0;
          c1.style.opacity = 1;
          c3.style.opacity = 0;
        };
        a3.onclick = function () {
          c2.style.opacity = 0;
          c1.style.opacity = 0;
          c3.style.opacity = 1;
        };
      };
    </script>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      #tab li {
        float: left;
        list-style: none;
      }
      #tab li a {
        display: inline-block;
        text-decoration: none;
        width: 80px;
        height: 40px;
        line-height: 40px;
        text-align: center;
        color: #000;
      }
      #container {
        position: relative;
      }
      #content1,
      #content2,
      #content3 {
        width: 300px;
        height: 100px;
        padding: 30px;
        position: absolute;
        top: 40px;
        left: 0;
      }
      #tab li:first-child,
      #content1 {
        background-color: aquamarine;
      }
      #tab li:first-child + li,
      #content2 {
        background-color: yellow;
      }
      #tab li:first-child + li + li,
      #content3 {
        background-color: blueviolet;
      }
      #content2,
      #content3 {
        opacity: 1;
      }
    </style>
  </head>
  <body>
    <h2>实现多标签效果</h2>
    <div class="tabs">
      <ul id="tab">
        <li>
          <a href="#content1" data-button="tab" data-id="content1" id="a1"
            >10元套餐</a
          >
        </li>
        <li>
          <a href="#content2" data-button="tab" data-id="content2" id="a2"
            >30元套餐</a
          >
        </li>
        <li>
          <a href="#content3" data-button="tab" data-id="content3" id="a3"
            >50元包月</a
          >
        </li>
      </ul>
      <div id="container">
        <div id="content1" style="z-index: 21">
          "10元套餐详情："
          <br />
          "&nbsp;每月套餐内拨打100分钟：超出部分两毛/分钟"
        </div>
        <div id="content2" style="z-index: 21">
          "30元套餐详情："
          <br />
          "&nbsp;每月套餐内拨打300分钟：超出部分1.5毛/分钟"
        </div>
        <div id="content3" style="z-index: 21">
          "50元套餐包月："
          <br />
          "&nbsp;每月无限量"
        </div>
      </div>
    </div>
  </body>
</html>
